<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
	<jsp:include page="/jsp/css.jsp"/>
	<div class="sidebar">
        <div class="sidebar-dropdown"><a href="#">导航</a></div>
        <ul id="nav">
          <!-- Main menu with font awesome icon -->
          <li><a href="${pageContext.request.contextPath}/index.jsp" class="open"><i class="icon-home"></i> 首页</a></li>
         </ul>
    </div>
    <div id="d22"></div>
	<jsp:include page="/jsp/js.jsp"/>	
    <script type="text/javascript">
		$(function(){
			$.ajax({
				url : "${pageContext.request.contextPath}/menu/getMenuListJSON.action",
				type : "POST",
				dataType : "json", 
				data : {},
				success : function(result, start, resp) {
					var  str ='';
				    for(var i=0;i<result.length;i++){
				    	var s1=result[i].uuid;
				    	var str2="";
				    	str+='<li class="has_sub" value="'+result[i].uuid+'"><a href="#"><i class="icon-list-alt"></i>'+result[i].name+'<span class="pull-right"><i class="icon-chevron-right"></i></span></a><ul>';
				    	for(var j=1;j<result.length;j++){
				    		if(s1==result[j].puuid){
					    		str2+='<li value="'+result[j].uuid+'"><a href="${pageContext.request.contextPath}/'+result[j].url+'" >'+result[j].name+'</a></li>';
					    		i++;
					    	}
					    }
				    		str=str+str2+"</ul></li>";
				    }    
					$("#nav").append(str); 
					
					 $(window).resize(function()
							  {
							    if($(window).width() >= 765){
							      $(".sidebar #nav").slideDown(350);
							    }
							    else{
							      $(".sidebar #nav").slideUp(350); 
							    }
							  });


							  $("#nav > li > a").on('click',function(e){
							      if($(this).parent().hasClass("has_sub")) {
							        e.preventDefault();
							      }   

							      if(!$(this).hasClass("subdrop")) {
							        // hide any open menus and remove all other classes
							        $("#nav li ul").slideUp(350);
							        $("#nav li a").removeClass("subdrop");
							        
							        // open our new menu and add the open class
							        $(this).next("ul").slideDown(350);
							        $(this).addClass("subdrop");
							      }
							      
							      else if($(this).hasClass("subdrop")) {
							        $(this).removeClass("subdrop");
							        $(this).next("ul").slideUp(350);
							      } 
							      
							  });
							  
							  
							  
							   $(".sidebar-dropdown a").on('click',function(e){
							      e.preventDefault();

							      if(!$(this).hasClass("open")) {
							        // hide any open menus and remove all other classes
							        $(".sidebar #nav").slideUp(350);
							        $(".sidebar-dropdown a").removeClass("open");
							        
							        // open our new menu and add the open class
							        $(".sidebar #nav").slideDown(350);
							        $(this).addClass("open");
							      }
							      
							      else if($(this).hasClass("open")) {
							        $(this).removeClass("open");
							        $(".sidebar #nav").slideUp(350);
							      }
							  });

				}
			});
		});	
	</script> 